<template>
  <div class="container">
    <topTitle
      :titleText="titleText"
      :back="back"
      @gobackTriser="goBack"
    ></topTitle>
    <div class="mainCon">
      <el-form :model="formData" ref="formData" class="demo-formData">
        <table cellspacing="0" cellpadding="0" class="detailTable">
          <tbody>
            <tr>
              <td class="title">项目名称</td>
              <td>{{ formData.projectName || '--' }}</td>
              <td class="title">施工方名称</td>
              <!-- <td class="title">责任主体证件号码</td> -->
              <td>{{ formData.pbName || '--' }}</td>
            </tr>
            <tr>
              <td class="title">发生地区</td>
              <td>{{ formData.address || '--' }}</td>
              <td class="title">施工方统一社会信用代码</td>
              <td>{{ formData.pbUscc || '--' }}</td>
            </tr>
            <tr>
              <td class="title">行业</td>
              <td>{{ formData.industry || '--' }}</td>
              <td class="title">
                {{
                  formData.responsibilityType === 'COMPANY'
                    ? '责任主体统一社会信用代码'
                    : '责任主体身份证号码'
                }}
              </td>
              <!-- <td class="title">责任主体证件号码</td> -->
              <td>{{ formData.uscc || '--' }}</td>
            </tr>
            <tr>
              <td class="title">事项时间</td>
              <td>{{ formData.disputeDate }}</td>
              <td class="title">
                {{
                  formData.responsibilityType === 'COMPANY'
                    ? '责任主体企业名称'
                    : '责任主体姓名'
                }}
              </td>
              <td>
                {{
                  formData.companyName +
                    '(' +
                    formData.responsibilityTypeDesc +
                    ')' || '--'
                }}
              </td>
            </tr>
            <tr>
              <td class="title">是否下达整改文书</td>
              <td>{{ formData.isCorrected || '--' }}</td>
              <td class="title">事项程度</td>
              <td v-if="formData.disputeRank == '一般'" class="general">
                {{ formData.disputeRank || '--' }}
              </td>
              <td v-else-if="formData.disputeRank == '重大'" class="import">
                {{ formData.disputeRank || '--' }}
              </td>
              <td v-else-if="formData.disputeRank == '严重'" class="serious">
                {{ formData.disputeRank || '--' }}
              </td>
            </tr>
            <tr>
              <td class="title">是否欠薪</td>
              <td>
                {{
                  formData.isBackPay
                    ? '是 （涉及金额：' +
                      formData.balance +
                      '元，涉及人数：' +
                      formData.peopleTotal +
                      '人）'
                    : '否'
                }}
              </td>
              <td class="title">是否约谈</td>
              <td>{{ formData.isInterviewed || '--' }}</td>
            </tr>
            <tr>
              <td class="title">是否强制执行</td>
              <td>{{ formData.isEnforced || '--' }}</td>
              <td class="title">是否处理</td>
              <td>{{ formData.isHandled || '--' }}</td>
            </tr>
            <tr>
              <td class="title">是否移交公安</td>
              <td>{{ formData.isTransfered || '--' }}</td>
              <td class="title">是否立案</td>
              <td>{{ formData.isRegistered || '--' }}</td>
            </tr>
            <tr>
              <td class="title">事项类别</td>
              <td>{{ formData.preciseTypeName || '--' }}</td>
              <td class="title">是否处罚</td>
              <td>{{ formData.isPunished || '--' }}</td>
            </tr>
            <tr>
              <td class="title">案号</td>
              <td colspan="3">{{ formData.reference || '--' }}</td>
            </tr>
            <tr>
              <td class="title">事项情况</td>
              <td colspan="3">{{ formData.illustration || '--' }}</td>
            </tr>
            <tr>
              <td class="title">处理结果</td>
              <td colspan="3">{{ formData.result || '--' }}</td>
            </tr>
            <tr>
              <td class="title">上传事项资料</td>
              <td colspan="3" v-if="formData.fileList.length > 0">
                <!-- <template v-for="(item,index) in formData.fileList">
                <div class="interval" :key="index"><a target="_blank" class="a_link mouseOn" :href="item.absolutePath">{{item.originalName || "--"}}</a></div>
              </template> -->
                <el-link type="primary" @click="show()">查看</el-link>
              </td>
              <td colspan="3" v-else>--</td>
            </tr>
          </tbody>
        </table>
        <el-dialog
          title="上传事项资料"
          :visible.sync="seeUploadDialog"
          :modal-append-to-body="false"
          width="900px"
          :append-to-body="true"
        >
          <contractEnclosure :isShowType="false" :tableData="uploadDataList" />
        </el-dialog>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  name: 'detailSuperviseItem',

  data() {
    return {
      titleText: '违法记载详情',
      back: true,
      disputeRanks: [],
      formData: {
        id: '',
        typeId: '', //事项类型（字典）
        accidentId: '', //事项原因（字典）
        accidentDate: '', //2019/11/19--事项发生日期
        address: '', //--事项发生地址
        accidentRank: '', //--事项级别（枚举：01-一般，05-严重，10-重大
        involvedRangeId: '', //--涉案人数区间（字典）
        preciseTypeName: '', //事项类别
        illustration: '', //--事项说明
        projectName: '', //--项目名称
        uscc: '', //--企业USCC
        companyName: '', //--企业名称
        industryId: '', //--行业ID
        industry: '', //--行业
        areaId: '', //--1502区域Id
        responsibilityType: '', //主体类型
        isBackPay: '', //是否欠薪
        balance: '', //涉及金额
        peopleTotal: '', //涉及人数
        result: '', //处理结果
        fileList: [],
        reference: '',
      },
      uploadDataList: [],
      seeUploadDialog: false,
    }
  },
  created() {
    this.formData.id = this.$route.query.id
    this.getDetail(this.formData.id)
    this.getRank() //事项程度
  },
  activated() {},

  methods: {
    getRank() {
      this.axios({
        method: 'post',
        url: 'api-r/rightsdispute/expand/getRank',
        data: {},
      })
        .then((response) => {
          this.disputeRanks = response.data.result
        })
        .catch((error) => {
          this.$message({
            showClose: true,
            duration: 3000,
            message: '获取事项程度数据失败',
            type: 'error',
          })
        })
    },
    getDetail(id) {
      this.axios({
        method: 'post',
        url: 'api-r/rightsdispute/expand/detailbycompany',
        data: {
          id: id,
        },
      })
        .then((response) => {
          var data = response.data.result
          this.formData.id = data.id
          this.formData.disputeDate = data.disputeDate //--纠纷发生日期
          this.formData.disputeRank = data.disputeRank
          this.formData.address = data.areaName //--纠纷发生地点
          this.formData.industry = data.industry //--纠纷发生地点

          this.formData.illustration =
            data.illustration == 0 || data.illustration == 1
              ? data.illustration == 1
                ? '是'
                : '否'
              : '' //--纠纷说明
          this.formData.isInterviewed =
            data.isInterviewed == 0 || data.isInterviewed == 1
              ? data.isInterviewed == 1
                ? '是'
                : '否'
              : '' //--是否约谈（0-否，1-是）
          this.formData.isHandled =
            data.isHandled == 0 || data.isHandled == 1
              ? data.isHandled == 1
                ? '是'
                : '否'
              : '' //--是否处理（0-否，1-是）
          this.formData.isCorrected =
            data.isCorrected == 0 || data.isCorrected == 1
              ? data.isCorrected == 1
                ? '是'
                : '否'
              : '' //--是否责令整改（0-否，1-是）
          this.formData.isRegistered =
            data.isRegistered == 0 || data.isRegistered == 1
              ? data.isRegistered == 1
                ? '是'
                : '否'
              : '' //--是否立案（0-否，1-是）
          this.formData.isPunished =
            data.isPunished == 0 || data.isPunished == 1
              ? data.isPunished == 1
                ? '是'
                : '否'
              : '' //--是否处罚（0-否，1-是）
          this.formData.isTransfered =
            data.isTransfered == 0 || data.isTransfered == 1
              ? data.isTransfered == 1
                ? '是'
                : '否'
              : '' //--是否移交公安（0-否，1-是）
          this.formData.isEnforced =
            data.isEnforced == 0 || data.isEnforced == 1
              ? data.isEnforced == 1
                ? '是'
                : '否'
              : '' //--是否强制执行（0-否，1-是）
          this.formData.areaId = data.areaId //--纠纷区域编码（非项目区域编码）
          this.formData.projectName = data.projectName //--项目名称
          this.formData.uscc = data.uscc //--企业USCC
          this.formData.companyName = data.companyName //--企业名字
          this.formData.fileList = data.file
          this.formData.illustration = data.illustration
          this.formData.preciseTypeName = data.preciseTypeName //事项类别
          this.formData.responsibilityType = data.responsibilityType
          this.formData.responsibilityTypeDesc = data.responsibilityTypeDesc
          this.formData.isBackPay = data.isBackPay
          if (this.formData.isBackPay) {
            this.formData.balance = data.balance
            this.formData.peopleTotal = data.peopleTotal
          }
          this.formData.result = data.result
          this.formData.pbName = data.pbName //--施工方名称
          this.formData.pbUscc = data.pbUscc //--施工方USCC
          this.formData.reference = data.reference
          this.disputeRanks.forEach((item) => {
            if (item.id == data.disputeRank) {
              this.formData.disputeRank = item.name
            }
          })
        })
        .catch((error) => {
          this.$message.error('数据获取失败')
        })
    },
    goBack() {
      this.$router.push('/home/events/superviseEvent')
      this.$store.commit('GOBACK_NAME', {
        oldUrl: '/home/events/superviseEvent',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    show() {
      this.seeUploadDialog = true
      this.uploadDataList = this.formData.fileList
    },
  },
}
</script>
<style scoped lang="less">
.container {
  .mainCon {
    padding-left: 24px;
    padding-right: 24px;
    padding-bottom: 24px;
    height: calc(100% - 67px);
    color: #333;
    font-size: 14px;
    overflow-y: auto;
  }
}
form.el-form.demo-formData {
  width: 100%;
  display: inline-block;
  text-align: left;
  .a_link {
    color: #00a0e9;
  }
  table {
    width: 100%;
    border-top: 1px solid #dbdbdb;
    border-left: 1px solid #dbdbdb;
    td {
      // padding: 0 18px;
      height: 41px;
      // line-height: 41px;
      padding: 11px 14px;
      border-bottom: 1px solid #dbdbdb;
      border-right: 1px solid #dbdbdb;
    }
    .title {
      width: 220px;
      background-color: #f8f9fb;
      font-weight: 500;
      text-align: right;
    }
    .general {
      color: #6dd400;
    }
    .import {
      color: #fa6400;
    }
    .serious {
      color: #e02020;
    }
  }
}
.el-main .el-form-item {
  margin-bottom: 20px;
}
</style>
